package com.haibara.codesubmiteval.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.haibara.codesubmiteval.model.entity.QuestionSubmit;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author AiChan
 * @description 针对表【question_sumbit(题目提交)】的数据库操作Mapper
 * @createDate 2024-12-20 13:17:36
 * @Entity com.haibara.condesubmiteval.model.entity.QuestionSubmit
 */
@Mapper
public interface QuestionSubmitMapper extends BaseMapper<QuestionSubmit> {
    @Select("SELECT qs.code " +
            "FROM question_submit qs " +
            "WHERE qs.isDelete = 0 AND qs.questionId = #{questionId} AND qs.userId = #{userId} " +
            "ORDER BY createTime DESC " +
            "LIMIT 0,1")
    String getHistoryCode(@Param("questionId") Long questionId, @Param("userId") Long userId);

    @Update("TRUNCATE question_submit")
    void cleanQuestionSubmit();
}




